<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class InitEggLottery extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        // 扭蛋机表
        Schema::create('activity_egg_lottery', function (Blueprint $table) {
            $table->comment = '扭蛋机表';
            
            $table->increments('id');
            $table->uuid('uuid')->index() ;

            $table->integer('activity_id')->nullable()->index()->comment('活动id');
            $table->integer('theme')->default(1)->index()->comment('扭蛋机机柜主题');
            $table->string('bg_image')->nullable()->comment('背景图');
            $table->string('image_3d')->nullable()->comment('3D图');

            $table->softDeletes();
            $table->timestamps();
        });

        Schema::table('activity_skus', function (Blueprint $table) {
            $table->integer('odds')->nullable()->comment('中奖几率, 30表示30%');
            $table->boolean('is_hidden_sku')->default(0)->index()->comment('是否隐藏款 0为否 1为是');
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::disableForeignKeyConstraints();
        Schema::dropIfExists('activity_egg_lottery');

        Schema::table('activity_skus', function (Blueprint $table) {
            $table->dropColumn('odds');
            $table->dropColumn('is_hidden_sku');
        });
    }
}
